var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/businessComponent/work-flow/WorkFlowPanel.tsx
var WorkFlowPanel_exports = {};
__export(WorkFlowPanel_exports, {
  default: () => WorkFlowPanel
});
module.exports = __toCommonJS(WorkFlowPanel_exports);
var import_icons = require("@ant-design/icons");
var import_antd = require("antd");
var import_react = __toESM(require("react"));
var import_baseComponent = require("../../baseComponent");
var import_businessComponent = require("../../businessComponent");
var import_functionalComponent = require("../../functionalComponent");
var import_util = require("../../util");
var import_NGSignatureImage = require("./NGSignatureImage");
var import_service = require("./service");
var import_util2 = require("./util");
var import_WFApprovalPoints = require("./WFApprovalPoints");
var import_WFCommonPhrases = require("./WFCommonPhrases");
var import_WFDynamicBranchWin = require("./WFDynamicBranchWin");
var import_WFDynamicNodeUserWin = require("./WFDynamicNodeUserWin");
var import_WFNodeUserSettingWin = require("./WFNodeUserSettingWin");
var import_WFNoticeUserSelect = require("./WFNoticeUserSelect");
var import_WFocusPointWin = require("./WFocusPointWin");
var import_WFRollBackNodeWin = require("./WFRollBackNodeWin");
var import_WFVerticalHisLayout = require("./WFVerticalHisLayout");
var import_WFVerticalPanel = require("./WFVerticalPanel");
var WorkFlowPanelContext = import_react.default.createContext({
  workFlowInfo: {}
});
var columnProps = {
  sortable: false,
  resizable: false,
  columnSort: false,
  tooltip: true
};
var hisColumns = [
  {
    ...columnProps,
    header: import_util2.NGLang.taskHisActor,
    dataIndex: "userName",
    flex: 2,
    width: 70,
    tooltip: ({ value, row }) => {
      return row.userId === "nextNodeInfo" ? "" : value;
    },
    render({ value, row, table }) {
      return row.userId === "nextNodeInfo" ? /* @__PURE__ */ import_react.default.createElement(NextNodeInfo, { table }) : value;
    }
  },
  {
    ...columnProps,
    header: import_util2.NGLang.taskHisMsg,
    dataIndex: "message",
    flex: 4,
    width: 150
  },
  // {
  //   ...columnProps,
  //   header: NGLang.taskHisActorDept,
  //   dataIndex: 'deptname',
  //   flex: 2,
  //   width: 120
  // },
  {
    ...columnProps,
    header: import_util2.NGLang.taskHisTime,
    dataIndex: "time",
    flex: 2,
    width: 120
  },
  {
    ...columnProps,
    header: import_util2.NGLang.attach,
    dataIndex: "fileCount",
    flex: 2,
    width: 60,
    render: function({ value, row }) {
      if (value) {
        return AttachIcon(row, value);
      }
    }
  },
  {
    ...columnProps,
    header: import_util2.NGLang.taskHisNode,
    dataIndex: "nodeName",
    tooltip: true,
    flex: 2,
    width: 70
  },
  {
    ...columnProps,
    header: import_util2.NGLang.taskHisTaskDes,
    flex: 2,
    dataIndex: "actionName",
    width: 70
  },
  {
    ...columnProps,
    header: import_util2.NGLang.taskHisDuration,
    dataIndex: "duration",
    flex: 1,
    width: 70
  },
  {
    ...columnProps,
    header: import_util2.NGLang.approvalPoint,
    dataIndex: "approvalPoints",
    flex: 1,
    width: 140,
    render: (record) => {
      return showApprovalPoints(record.value, record);
    }
  },
  {
    ...columnProps,
    header: import_util2.NGLang.taskHisSignature,
    dataIndex: "signatureId",
    flex: 1,
    width: 60,
    tooltip: false,
    align: "center",
    render: function({ value }) {
      return value && /* @__PURE__ */ import_react.default.createElement("img", { src: import_util.iup.getHttpUrl(value), width: 12, height: 12, alt: "" });
    }
  }
];
function WfSkeleton({ height = 180 }) {
  return /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      style: {
        ...import_util2.commonStyle.borderStyle,
        ...import_util2.commonStyle.backgroundStyle,
        padding: 8,
        margin: "0 5px 5px 5px",
        height: height - 5
      }
    },
    /* @__PURE__ */ import_react.default.createElement(import_antd.Skeleton, { active: true })
  );
}
function NextNodeInfo({ table }) {
  const { workFlowInfo, bizType, bizPhId } = (0, import_react.useContext)(WorkFlowPanelContext);
  const [loading, setLoading] = (0, import_react.useState)(false);
  const hisAddNextNodeInfo = (0, import_util.useRefCallback)(async (e) => {
    var _a;
    e.stopPropagation();
    setLoading(true);
    const resp = await import_util.iup.request.body({
      url: "WorkFlow3/WorkFlow/GetNextTaskNodes",
      data: {
        data: {
          taskid: workFlowInfo.taskId,
          piid: workFlowInfo.procInstId,
          biztype: bizType || ((_a = import_util.iup.getPageInstance()) == null ? void 0 : _a.busType),
          bizphid: bizPhId
        }
      }
    });
    if (resp.code === 0) {
      const rows = [...table.getRows()];
      rows.pop();
      resp.data.forEach((d, index) => {
        if (index === 0) {
          rows.push({
            task_des: d.activityName + "[当前]",
            username: d.username || "空",
            actionname: d.actionname
          });
        } else {
          rows.push({
            task_des: d.activityName + "[后续]",
            username: d.username || "空"
          });
        }
      });
      table.setDataSource(rows);
    } else {
      await (0, import_util2.wfAlert)(import_util2.NGLang.alertTitle, resp.message);
      setLoading(false);
    }
  });
  return /* @__PURE__ */ import_react.default.createElement(
    "a",
    {
      onClick: hisAddNextNodeInfo,
      style: {
        whiteSpace: "nowrap",
        fontSize: 12,
        zIndex: 1,
        top: 0,
        bottom: 0,
        left: 0,
        position: "absolute",
        display: "flex",
        alignItems: "center",
        paddingLeft: 6,
        width: table.state.width
      }
    },
    loading ? /* @__PURE__ */ import_react.default.createElement(import_icons.LoadingOutlined, { style: { marginRight: 2 } }) : /* @__PURE__ */ import_react.default.createElement(import_icons.DownOutlined, { style: { marginRight: 2 } }),
    import_util2.NGLang.showNextNodeInfo
  );
}
function AttachIcon(record, value) {
  return /* @__PURE__ */ import_react.default.createElement(import_antd.Badge, { size: "small", count: record.att_count, offset: [8, 6] }, /* @__PURE__ */ import_react.default.createElement("a", { onClick: () => (0, import_util2.showTaskAttachment)(record, 0) }, /* @__PURE__ */ import_react.default.createElement(import_icons.PaperClipOutlined, null), value));
}
function showApprovalPoints(value, record) {
  if (value) {
    return /* @__PURE__ */ import_react.default.createElement("span", null, /* @__PURE__ */ import_react.default.createElement(
      import_icons.FileSearchOutlined,
      {
        onClick: () => {
          var _a;
          (0, import_util2.wfModal)({
            title: import_util2.NGLang.approvalPoint,
            width: 800,
            content: /* @__PURE__ */ import_react.default.createElement(
              import_WFApprovalPoints.WFApprovalPoints,
              {
                approvalPointsData: (_a = record.row) == null ? void 0 : _a.approvalPointRuntimeDtoList,
                cancelBack: import_util2.reloadPage,
                view: true
              }
            )
          });
        }
      }
    ), value);
  } else {
    return "";
  }
}
function HistoryTable({ dataSource }) {
  const { workFlowInfo = {}, bizType, bizPhId } = (0, import_react.useContext)(WorkFlowPanelContext);
  const requestHisList = (0, import_react.useMemo)(() => {
    return async () => {
      if (dataSource) {
        return dataSource;
      }
      const hisData = await (0, import_service.getWorkFlowHis)({ procInstId: workFlowInfo.procInstId || "" });
      if (workFlowInfo.taskId) {
        hisData.push({ username: import_util2.NGLang.showNextNodeInfo, user_id_: "nextNodeInfo" });
      }
      return hisData;
    };
  }, [dataSource, workFlowInfo.procInstId, bizType, bizPhId]);
  const onDataLoad = (0, import_util.useRefCallback)((table) => {
    table.setSelected(0);
  });
  return /* @__PURE__ */ import_react.default.createElement(
    import_functionalComponent.Table,
    {
      rowHeight: 30,
      onDataLoad,
      rowSelected: true,
      headerHeight: 32,
      style: import_util2.commonStyle.borderStyle,
      columns: hisColumns,
      request: requestHisList
    }
  );
}
var InnerWorkFlowPanel = (0, import_react.memo)((props) => {
  var _a, _b, _c, _d;
  console.log(props, "props");
  return /* @__PURE__ */ import_react.default.createElement(WorkFlowPanelContext.Provider, { value: props }, ((_a = props.workFlowInfo) == null ? void 0 : _a.taskId) && props.direction === "vertical" && /* @__PURE__ */ import_react.default.createElement(WfLayout, null), !((_b = props.workFlowInfo) == null ? void 0 : _b.taskId) && props.direction === "vertical" && /* @__PURE__ */ import_react.default.createElement(import_WFVerticalHisLayout.WFVerticalHisLayout, { workFlowInfo: props.workFlowInfo }), ((_c = props.workFlowInfo) == null ? void 0 : _c.taskId) && props.direction !== "vertical" && /* @__PURE__ */ import_react.default.createElement(WfLayout, null), !((_d = props.workFlowInfo) == null ? void 0 : _d.taskId) && props.direction !== "vertical" && /* @__PURE__ */ import_react.default.createElement(HisLayout, null));
});
function HisLayout() {
  const { workFlowInfo, height, bizPhId, bizType, toolbar } = (0, import_react.useContext)(WorkFlowPanelContext);
  const [hisData, setHisData] = (0, import_util.useRefState)([]);
  const [loading, setLoading] = (0, import_util.useRefState)(true);
  (0, import_react.useEffect)(() => {
    if (workFlowInfo.wfotype === "processNotify") {
      (0, import_service.updateNotificationReadFlg)({ piId: workFlowInfo.procInstId });
    }
  }, [workFlowInfo.wfotype, workFlowInfo.procInstId]);
  (0, import_util.useAllReady)(() => {
    (0, import_util2.setWorkFlowUIState)(workFlowInfo.formDataPermissions, workFlowInfo.menuPermissions);
  });
  (0, import_react.useEffect)(() => {
    (0, import_service.getWorkFlowHis)({ procInstId: workFlowInfo.procInstId || "" }).then((data) => {
      setLoading(false);
      setHisData(data);
      if (data.length > 0 && toolbar) {
        const tb = (0, import_util2.getToolbar)(toolbar);
        tb == null ? void 0 : tb.insert({
          id: "wfbtn_flowinfo",
          text: import_util2.NGLang.flowInfo,
          icon: "HistoryOutlined",
          onClick: async () => {
            var _a;
            await (0, import_util2.showFlowInfo)(bizType || ((_a = import_util.iup.getPageInstance()) == null ? void 0 : _a.busType), bizPhId);
          }
        });
      }
    });
  }, [workFlowInfo.procInstId, bizPhId, bizType]);
  if (!hisData.length) {
    return loading ? /* @__PURE__ */ import_react.default.createElement(WfSkeleton, { height }) : null;
  }
  return /* @__PURE__ */ import_react.default.createElement(
    import_util.Layout,
    {
      direction: "row",
      style: {
        height,
        padding: 5,
        backgroundColor: "var(--component-background)",
        marginBottom: "var(--inner-margin, 16px)"
      }
    },
    /* @__PURE__ */ import_react.default.createElement(import_util.Layout.Flex, null, /* @__PURE__ */ import_react.default.createElement(HistoryTable, { dataSource: hisData }))
  );
}
function FormItem({ children, style = {}, label = "", flex = 1 }) {
  return /* @__PURE__ */ import_react.default.createElement("label", { style: { flex, display: "flex", alignItems: "center", ...style } }, label && /* @__PURE__ */ import_react.default.createElement("span", { style: { marginRight: 4 } }, label, ":"), /* @__PURE__ */ import_react.default.createElement("span", { style: { flex: 1 } }, children));
}
function WfLayout() {
  const {
    workFlowInfo,
    height = 180,
    isFromPortal,
    refreshTaskList,
    bizType,
    bizPhId,
    bizSaveFn,
    bizRollbackSaveFn,
    getAttachData,
    onTaskComplete,
    toolbar,
    showAllToolBar,
    showToolBarItems,
    taskDealInfo: initState,
    direction
  } = (0, import_react.useContext)(WorkFlowPanelContext);
  const signatureRef = (0, import_react.useRef)();
  const addSubTaskLeftTable = (0, import_react.useRef)();
  const addSubTaskRightTable = (0, import_react.useRef)();
  const reassignTable = (0, import_react.useRef)();
  const copyLeftTable = (0, import_react.useRef)();
  const copyRightTable = (0, import_react.useRef)();
  const taskDealInfo = (0, import_react.useMemo)(() => {
    return {
      ...initState,
      taskId: workFlowInfo.taskId,
      piid: workFlowInfo.procInstId,
      biztype: bizType,
      bizphid: bizPhId,
      attguid: ""
    };
  }, [initState]);
  const [msg, setMsg] = (0, import_react.useState)({
    system_message: false,
    // 消息自由呼通知
    mobile_message: false
    // 移动消息通知
  });
  const [commonWordHelp, setCommonWordHelp] = (0, import_react.useState)(new Array());
  const signature = (0, import_react.useMemo)(() => {
    return {
      code: workFlowInfo.defaultSignature || "",
      url: workFlowInfo.defaultSignature && workFlowInfo.signatureUrl ? import_util.iup.getHttpUrl(workFlowInfo.signatureUrl) : ""
    };
  }, [workFlowInfo]);
  const onSuggestChange = (0, import_util.useRefCallback)((sv) => {
    import_util.iup.getCmp("SuggestValue").getApi().setValue((sv == null ? void 0 : sv.label) || "");
  });
  const onSignatureChange = (0, import_util.useRefCallback)((value) => {
    signatureRef.current = value;
  });
  (0, import_react.useEffect)(() => {
    (0, import_service.getCommonWordHelp)().then((res) => {
      setCommonWordHelp(res);
    });
  }, []);
  const columns = [
    { title: "用户编号", dataIndex: "userNo" },
    { title: "用户名称", dataIndex: "userName" },
    { title: "所属组织", dataIndex: "belongorgName" },
    { title: "所属部门", dataIndex: "belongDeptName" }
  ];
  const tableProps = {
    checkbox: "checked",
    bordered: true,
    tooltip: true,
    style: { height: 500 },
    rowChecked: true,
    rowSelected: false,
    columns
  };
  const btnStyles = {
    width: 50,
    height: 24,
    margin: "8px 10px"
  };
  const ModalTableDom = ({ btnType, leftTableRef, rightTableRef }) => {
    const getLeftTable = () => leftTableRef.current.getApi();
    const getRightTable = () => rightTableRef.current.getApi();
    const dataRequest = async () => {
      const tableData = JSON.parse(JSON.stringify(workFlowInfo.processOperateOptions[btnType].userInfos));
      await import_util.iup.delay(100);
      return tableData;
    };
    const toRightTable = () => {
      const leftSelectData = getLeftTable().getSelectedData();
      const rightTableData = getRightTable().getData();
      const willToRightData = leftSelectData.filter(
        (leftItem) => rightTableData.findIndex((rightItem) => rightItem.id === leftItem.id) === -1
      );
      if (willToRightData.length) {
        const ldata = willToRightData.map((v) => {
          return {
            ...v,
            checked: false
          };
        });
        getRightTable().setDataSource([...ldata]);
      }
    };
    const allToRightTable = () => {
      const leftTableData = getLeftTable().getData();
      const ldata = leftTableData.map((v) => {
        return {
          ...v,
          checked: false
        };
      });
      getRightTable().setDataSource([...ldata]);
    };
    const toLeftTable = () => {
      if (getRightTable().getSelectedData().length) {
        const rightTableData = getRightTable().getData();
        const rdata = rightTableData.filter((v) => !v.checked);
        getRightTable().setDataSource([...rdata]);
      }
    };
    const allToLeftTable = () => {
      getRightTable().setDataSource([]);
    };
    return /* @__PURE__ */ import_react.default.createElement("div", { style: { display: "flex", alignItems: "center", padding: "0 1px" } }, /* @__PURE__ */ import_react.default.createElement("div", { style: { width: "calc(50% - 50px)" } }, /* @__PURE__ */ import_react.default.createElement(import_functionalComponent.Table, { ...tableProps, pagination: { pageSize: 15 }, request: dataRequest, ref: leftTableRef })), /* @__PURE__ */ import_react.default.createElement(
      "div",
      {
        style: {
          width: 100,
          height: "100%",
          textAlign: "center",
          display: "flex",
          flexDirection: "column",
          justifyContent: "center",
          alignItems: "center"
        }
      },
      /* @__PURE__ */ import_react.default.createElement(import_functionalComponent.Button, { size: "small", icon: /* @__PURE__ */ import_react.default.createElement(import_icons.RightOutlined, null), style: btnStyles, onClick: toRightTable }),
      /* @__PURE__ */ import_react.default.createElement(import_functionalComponent.Button, { size: "small", icon: /* @__PURE__ */ import_react.default.createElement(import_icons.DoubleRightOutlined, null), style: btnStyles, onClick: allToRightTable }),
      /* @__PURE__ */ import_react.default.createElement(import_functionalComponent.Button, { size: "small", icon: /* @__PURE__ */ import_react.default.createElement(import_icons.LeftOutlined, null), style: btnStyles, onClick: toLeftTable }),
      /* @__PURE__ */ import_react.default.createElement(import_functionalComponent.Button, { size: "small", icon: /* @__PURE__ */ import_react.default.createElement(import_icons.DoubleLeftOutlined, null), style: btnStyles, onClick: allToLeftTable })
    ), /* @__PURE__ */ import_react.default.createElement("div", { style: { width: "calc(50% - 50px)" } }, /* @__PURE__ */ import_react.default.createElement(import_functionalComponent.Table, { ...tableProps, ref: rightTableRef })));
  };
  const options = {
    taskDynamicInfo: {},
    // 判断是否输入办理意见、消息通知等
    isValid: async () => {
      const remark = import_util.iup.getCmp("SuggestValue").getApi().getValue();
      const minRemarkLen = Number(workFlowInfo.minCommentLen) || Number(workFlowInfo.mincommentlen) || 0;
      if (!remark && minRemarkLen !== 0) {
        await (0, import_util2.wfMessage)(import_util2.NGLang.hasNoremark);
        return false;
      } else if (remark && remark.length < minRemarkLen) {
        await (0, import_util2.wfMessage)((0, import_util2.stringFormat)(import_util2.NGLang.reamrkHasMore, minRemarkLen));
        return false;
      }
      taskDealInfo.comment = taskDealInfo.comment ? taskDealInfo.comment : {};
      taskDealInfo.comment.content = remark;
      console.log(taskDealInfo, "taskDealInfotaskDealInfo");
      if (workFlowInfo.needsignature && !taskDealInfo.comment.signatureId) {
        await (0, import_util2.wfMessage)((0, import_util2.stringFormat)(import_util2.NGLang.mustSignature, minRemarkLen));
        return false;
      }
      if (msg.system_message || msg.mobile_message) {
        const msgText = import_util.iup.getCmpApi("messageContent").getValue();
        if (!msgText) {
          await (0, import_util2.wfMessage)(import_util2.NGLang.hasNoMsgContent);
          return false;
        }
        const msgUser = import_util.iup.getCmpApi("messageUsers").getValue();
        if (!(msgUser == null ? void 0 : msgUser.length)) {
          await (0, import_util2.wfMessage)(import_util2.NGLang.hasNoMsgReceiver);
          return false;
        }
        taskDealInfo.noticeInfo = {
          systemMsg: msg.system_message,
          mobileMsg: msg.mobile_message,
          msgText,
          users: msgUser.map((u) => u.userId)
        };
      }
      return true;
    },
    // 判断是否输入办理意见、消息通知及调用业务单据保存
    validAndSaveBiz: async (opType, valid = true) => {
      const validResult = valid ? await options.isValid() : true;
      if (validResult) {
        if (workFlowInfo.bizApproved) {
          return true;
        }
        if (bizSaveFn && bizSaveFn !== import_util.emptyFn) {
          const bizSaveReturn = await bizSaveFn();
          if (bizSaveReturn === false) {
            return false;
          }
          await options.setBizAttachData(opType);
        }
        return true;
      }
      return false;
    },
    // 刷新首页portal
    refreshPortalEx: () => {
      import_util.iup.refreshList("MyWorkFlowTask", { type: "save" });
    },
    alertAndClose: async (msgContent) => {
      await (0, import_util2.wfAlert)(import_util2.NGLang.alertTitle, msgContent);
      await import_util.iup.close();
    },
    // 设置业务组件附加数据
    setBizAttachData: async (opType) => {
      if (getAttachData && getAttachData !== import_util.emptyFn) {
        const tempData = await getAttachData(opType);
        if (import_util.iup.isObject(tempData)) {
          taskDealInfo.bizAttachData = tempData;
        }
      }
    },
    // 成功执行某个任务后关闭当前页面
    successAlertAndClose: async (msgContent) => {
      console.log("触发成功执行某个任务后关闭当前页面");
      options.refreshPortalEx();
      if (isFromPortal && (0, import_util2.getAutoNextFlag)()) {
        const nextTaskData = await (0, import_util2.getNextTask)({ taskid: workFlowInfo.taskId, catalogGroup: isFromPortal });
        if (nextTaskData == null ? void 0 : nextTaskData.id) {
          await (0, import_functionalComponent.usingProgress)(() => import_util.iup.delay(1500), { title: `${msgContent},${import_util2.NGLang.openNextTask}` });
          await (0, import_util2.openNextAppFlowTask)({ nextTaskData, isFromPortal, isTaskList: false });
        } else {
          await options.alertAndClose(msgContent);
        }
      } else {
        await options.alertAndClose(msgContent);
      }
    },
    // 流程终止
    flowTerminate: async (step) => {
      var _a;
      if (step === 1) {
        if (await options.isValid()) {
          await options.flowTerminate(2);
        }
      } else if (step === 2) {
        if (await (0, import_util2.wfConfirm)(import_util2.NGLang.alertTitle, import_util2.NGLang.whetherTerminate)) {
          taskDealInfo.biztype = taskDealInfo.biztype || ((_a = import_util.iup.getPageInstance()) == null ? void 0 : _a.busType);
          const resp = await import_util.iup.request.body({
            url: "workflow/task/terminateProcessByTask",
            data: { ...taskDealInfo }
          });
          if (resp.code === 0) {
            await options.successAlertAndClose(import_util2.NGLang.terminateSuccess);
          } else {
            await (0, import_util2.wfAlert)(import_util2.NGLang.terminateFailure, resp.message);
          }
        }
      }
    },
    // 加签
    addSubTasks: async (step) => {
      if (step === 1) {
        if (await options.validAndSaveBiz("addSubTasks")) {
          await options.addSubTasks(2);
        }
      } else if (step === 2) {
        taskDealInfo.parentAutoComplete = !!workFlowInfo.whetherRepeatedlyAddSubTask;
        taskDealInfo.sequential = false;
        if (!!workFlowInfo.processOperateOptions.addSubTask && !!workFlowInfo.processOperateOptions.addSubTask.userInfos) {
          (0, import_functionalComponent.showModal)({
            title: "加签人员选择",
            width: 1e3,
            content: /* @__PURE__ */ import_react.default.createElement(
              ModalTableDom,
              {
                btnType: "addSubTask",
                leftTableRef: addSubTaskLeftTable,
                rightTableRef: addSubTaskRightTable
              }
            ),
            footerLeft: /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(import_baseComponent.Checkbox, { style: { float: "right", marginRight: 5 }, onChange: (v) => taskDealInfo.sequential = !!v }, import_util2.NGLang.sequential), /* @__PURE__ */ import_react.default.createElement(
              import_baseComponent.Checkbox,
              {
                style: { float: "right", marginRight: 5 },
                disabled: !!workFlowInfo.whetherRepeatedlyAddSubTask,
                defaultChecked: Number(!!workFlowInfo.whetherRepeatedlyAddSubTask),
                onChange: (v) => {
                  taskDealInfo.parentAutoComplete = !!v;
                }
              },
              import_util2.NGLang.parentAutoComplete
            )),
            async onOk() {
              const selectedData = addSubTaskRightTable.current.getApi().getData();
              taskDealInfo.users = selectedData.map(({ userNo }) => userNo);
              console.log(taskDealInfo, "加签信息");
              const resp = await (0, import_service.addSubTaskAsync)(taskDealInfo);
              if (resp.code === 0) {
                await options.successAlertAndClose(import_util2.NGLang.addSubTasksSuccess);
              } else {
                await (0, import_util2.wfAlert)(import_util2.NGLang.addSubTasksFailure, resp.message);
              }
            },
            onCancel(ins) {
              addSubTaskRightTable.current.getApi().setDataSource([]);
              ins.destroy();
            }
          });
        } else {
          const data = await import_util.iup.external.openHelp({
            type: "UserHelp",
            helpId: "user",
            title: import_util2.NGLang.selectAddPerson,
            multiple: true,
            // hasRight: false,
            footer: /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(
              import_baseComponent.Checkbox,
              {
                style: { float: "right", marginRight: 5 },
                disabled: !!workFlowInfo.whetherRepeatedlyAddSubTask,
                defaultChecked: Number(!!workFlowInfo.whetherRepeatedlyAddSubTask),
                onChange: (v) => {
                  taskDealInfo.parentAutoComplete = !!v;
                }
              },
              import_util2.NGLang.parentAutoComplete
            ), /* @__PURE__ */ import_react.default.createElement(import_baseComponent.Checkbox, { style: { float: "right", marginRight: 5 }, onChange: (v) => taskDealInfo.sequential = !!v }, import_util2.NGLang.sequential))
          });
          if (data && data.length > 0) {
            taskDealInfo.users = data.map(({ origin }) => origin.PhId || origin.userNo);
            console.log(taskDealInfo, "加签信息");
            const resp = await (0, import_service.addSubTaskAsync)(taskDealInfo);
            if (resp.code === 0) {
              await options.successAlertAndClose(import_util2.NGLang.addSubTasksSuccess);
            } else {
              await (0, import_util2.wfAlert)(import_util2.NGLang.addSubTasksFailure, resp.message);
            }
          } else {
            (0, import_util2.reloadPage)();
          }
        }
      }
    },
    // 转签
    taskReassign: async (step) => {
      var _a;
      console.log("step", step);
      if (step === 1) {
        if (await options.validAndSaveBiz("taskReassign")) {
          await options.taskReassign(2);
        }
      } else if (step === 2) {
        if (!!workFlowInfo.processOperateOptions.reassign && !!workFlowInfo.processOperateOptions.reassign.userInfos) {
          const getReassignTable = () => reassignTable.current.getApi();
          const dataRequest = async () => {
            const tableData = [...workFlowInfo.processOperateOptions.reassign.userInfos];
            await import_util.iup.delay(100);
            return tableData;
          };
          (0, import_functionalComponent.showModal)({
            title: "转签人员选择",
            width: 1e3,
            content: /* @__PURE__ */ import_react.default.createElement(
              import_functionalComponent.Table,
              {
                ref: reassignTable,
                style: { height: 500 },
                rowSelected: true,
                pagination: { pageSize: 15 },
                columns: [
                  { title: "用户编号", dataIndex: "userNo" },
                  { title: "用户名称", dataIndex: "userName" },
                  { title: "所属组织", dataIndex: "belongorgName" },
                  { title: "所属部门", dataIndex: "belongDeptName" }
                ],
                request: dataRequest
              }
            ),
            async onOk() {
              var _a2;
              const selectedData = getReassignTable().getSelectedRow();
              if (!selectedData) {
                await (0, import_util2.wfAlert)(import_util2.NGLang.taskReassignError, import_util2.NGLang.taskReassignErrorMsg);
                return;
              }
              const { userNo, userName } = selectedData;
              taskDealInfo.assignee = userNo;
              taskDealInfo.biztype = taskDealInfo.biztype || ((_a2 = import_util.iup.getPageInstance()) == null ? void 0 : _a2.busType);
              console.log(taskDealInfo, "转签信息");
              const resp = await import_util.iup.request.body({
                url: "workflow/task/taskReassign",
                data: { ...taskDealInfo }
              });
              if (resp.code === 0) {
                await options.successAlertAndClose((0, import_util2.stringFormat)(import_util2.NGLang.taskReassSuccess, userName));
              } else {
                await (0, import_util2.wfAlert)(import_util2.NGLang.taskReassignError, resp.message);
              }
            },
            onCancel(ins) {
              getReassignTable().setDataSource([]);
              ins.destroy();
            }
          });
        } else {
          const data = await import_util.iup.external.openHelp({
            type: "UserHelp",
            title: import_util2.NGLang.selectReassignPerson,
            helpId: "user",
            multiple: false
            // hasRight: false
          });
          if (data) {
            taskDealInfo.assignee = data.origin.PhId || data.origin.userNo;
            taskDealInfo.biztype = taskDealInfo.biztype || ((_a = import_util.iup.getPageInstance()) == null ? void 0 : _a.busType);
            const resp = await import_util.iup.request.body({
              url: "workflow/task/taskReassign",
              data: { ...taskDealInfo }
            });
            if (resp.code === 0) {
              await options.successAlertAndClose((0, import_util2.stringFormat)(import_util2.NGLang.taskReassSuccess, data.origin.UserName));
            } else {
              await (0, import_util2.wfAlert)(import_util2.NGLang.taskReassignError, resp.message);
            }
          } else {
            (0, import_util2.reloadPage)();
          }
        }
      }
    },
    // 驳回
    rollBack: async (step) => {
      var _a;
      switch (step) {
        case 0: {
          if (await options.isValid()) {
            await options.rollBack(1);
          }
          break;
        }
        case 1: {
          if (workFlowInfo.preRollbackBizCheck) {
            const resp = await (0, import_functionalComponent.usingProgress)(() => (0, import_service.checkPreRollback)(workFlowInfo.taskId), {
              title: import_util2.NGLang.checkCancelApprove
            });
            if (resp.code === 0) {
              if (resp.data.state === 2) {
                await (0, import_util2.wfAlert)(import_util2.NGLang.canNotCancelApprove, resp.data.message);
              } else if (resp.data.state === 1) {
                if (await (0, import_util2.wfConfirm)(import_util2.NGLang.alertTitle, resp.data.message)) {
                  await options.rollBack(2);
                }
              } else {
                await options.rollBack(2);
              }
            } else {
              await (0, import_util2.wfAlert)(import_util2.NGLang.checkCancelApproveError, resp.message);
            }
          } else {
            await options.rollBack(2);
          }
          break;
        }
        case 2: {
          if (workFlowInfo.bizApproved) {
            await options.setBizAttachData("rollBack");
          }
          await (0, import_util2.wfModal)({
            title: import_util2.NGLang.rollBackNodeWinTitle,
            width: 600,
            footerLeft: /* @__PURE__ */ import_react.default.createElement(import_WFRollBackNodeWin.WFRollBackNodeWinFooter, null),
            content: /* @__PURE__ */ import_react.default.createElement(
              import_WFRollBackNodeWin.WFRollBackNodeWin,
              {
                taskId: workFlowInfo.taskId,
                callback: (data, dyUser) => {
                  taskDealInfo.rollbackTargetNodeId = data.toNodeId;
                  taskDealInfo.rollbackType = data.type;
                  taskDealInfo.rollbackTargetNodeName = data.name;
                  taskDealInfo.whetherProcessInitNode = data.whetherProcessInitNode;
                  if (data.receivers)
                    taskDealInfo.rollbackMessageReceivers = data.receivers;
                  options.rollBack(dyUser ? 3 : 4);
                }
              }
            )
          });
          break;
        }
        case 3: {
          const resp = await import_util.iup.request.get({
            url: "WorkFlow3/WorkFlow/GetNodeDynamicUser",
            data: {
              taskid: workFlowInfo.taskId,
              nodeid: taskDealInfo.nodeid
              // 这个字段从哪里来的？？？ Ext WorkFlowHelp.js 也是这么写的
            }
          });
          const dynamicType = [];
          if (resp.exists_user) {
            dynamicType.push(1);
            if (resp.dynamicAny) {
              dynamicType.push(2);
            }
          } else {
            dynamicType.push(2);
          }
          await (0, import_util2.wfModal)({
            title: `${resp.name || ""}${import_util2.NGLang.taskHisNode}--${import_util2.NGLang.dynamicUsers}`,
            width: 900,
            content: /* @__PURE__ */ import_react.default.createElement(
              import_WFDynamicNodeUserWin.WFDynamicNodeUserWin,
              {
                radioItems: dynamicType,
                todoData: resp.users,
                callBack: (data) => {
                  taskDealInfo.dynamicNodeUsers = data;
                  options.rollBack(4);
                }
              }
            )
          });
          break;
        }
        case 4: {
          if ((_a = workFlowInfo.sc_rejectReason) == null ? void 0 : _a.length) {
            await (0, import_util2.wfModal)({
              title: import_util2.NGLang.rollBackReason,
              width: 600,
              content: /* @__PURE__ */ import_react.default.createElement(
                import_WFRollBackNodeWin.WFRollBackReason,
                {
                  reasonData: workFlowInfo.sc_rejectReason,
                  callback: (id) => {
                    taskDealInfo.sc3RejectReason = id;
                    options.rollBack(5);
                  }
                }
              )
            });
          } else {
            await options.rollBack(5);
          }
          break;
        }
        case 5: {
          if (bizRollbackSaveFn && bizRollbackSaveFn !== import_util.emptyFn) {
            const bizRollbackSaveReturn = await bizRollbackSaveFn(
              taskDealInfo.rollbackTargetNodeId,
              taskDealInfo.whetherProcessInitNode
            );
          }
          const resp = await (0, import_functionalComponent.usingProgress)(() => (0, import_service.RollBack)(taskDealInfo), { title: import_util2.NGLang.submitRollBack });
          console.log(resp, "resp");
          if (resp.code === 0) {
            await options.successAlertAndClose(import_util2.NGLang.rollBackSuccess);
          } else {
            await (0, import_util2.wfAlert)(import_util2.NGLang.rollBackError, resp.message);
          }
          if (taskDealInfo.rollbackTargetNodeId) {
            delete taskDealInfo.rollbackTargetNodeId;
            delete taskDealInfo.rollbackType;
          }
          break;
        }
        default:
          break;
      }
    },
    // 确认事项
    handlerFocusPoint: async (callback) => {
      var _a, _b;
      const controls = [];
      const tdiFocusPoint = ((_a = taskDealInfo.focusPoint) == null ? void 0 : _a.split(";")) || [];
      (_b = workFlowInfo.focusPoint) == null ? void 0 : _b.forEach(function(d, i) {
        var _a2;
        const helpData = d.options.map((o) => ({ value: o.name, label: o.name }));
        d.tempId = "fc_ctl_" + i;
        const ctrl = {
          label: d.name,
          xtype: "NGSelect",
          name: d.tempId,
          required: true,
          data: helpData,
          colspan: 4
        };
        if (tdiFocusPoint) {
          ctrl.defaultValue = (_a2 = tdiFocusPoint.find((v) => v.indexOf(d.name + ":") === 0)) == null ? void 0 : _a2.split(":")[1];
        }
        controls.push(ctrl);
      });
      if (controls.length > 0) {
        await (0, import_util2.wfModal)({
          title: import_util2.NGLang.focusPoint,
          width: 600,
          content: /* @__PURE__ */ import_react.default.createElement(
            import_WFocusPointWin.WFocusPointWin,
            {
              callback: (fd) => {
                var _a2;
                taskDealInfo.focusPoint = (_a2 = workFlowInfo.focusPoint) == null ? void 0 : _a2.map(({ name, tempId }) => `${name}:${fd[tempId] || ""}`).join(";");
                callback == null ? void 0 : callback();
              },
              fields: controls
            }
          )
        });
      }
    },
    // 提交任务办理
    taskComplete: async (step) => {
      var _a, _b;
      switch (step) {
        case 0: {
          if (workFlowInfo.toDoOpinion === "1" && workFlowInfo.parentTaskId) {
            if (!await options.isValid()) {
              return;
            }
          }
          if (!await options.isValid()) {
            return;
          }
          if (workFlowInfo.focusPoint && !taskDealInfo.focusPoint) {
            await options.handlerFocusPoint(function() {
              options.taskComplete(5);
            });
            return;
          }
          if (workFlowInfo.approvalPoints) {
            if (workFlowInfo.approvalPoints.length > 0 && !taskDealInfo.approvalPoints) {
              options.approvalPoints(false, function() {
                options.taskComplete(5);
              });
            } else {
              await options.taskComplete(5);
            }
            return;
          }
          await options.taskComplete(5);
          break;
        }
        case 5: {
          if (workFlowInfo.bizApproved === false && bizSaveFn && bizSaveFn !== import_util.emptyFn) {
            if (!await options.validAndSaveBiz("taskComplete", false)) {
              return;
            }
          }
          await options.taskComplete(10);
          break;
        }
        case 10: {
          const resp = await (0, import_functionalComponent.usingProgress)(() => (0, import_service.checkPreCompleteTask)(workFlowInfo.taskId));
          if (resp.code === 0) {
            options.taskDynamicInfo = resp.data;
            taskDealInfo.nodeName = (_a = resp.data) == null ? void 0 : _a.nodeName;
            const { state, message } = (_b = resp.data) == null ? void 0 : _b.bizOperationCheckResult;
            if (state === 2) {
              await (0, import_util2.wfAlert)(import_util2.NGLang.alertTitle, message);
              (0, import_util2.reloadPage)();
            } else if (state === 1) {
              if (await (0, import_util2.wfConfirm)(import_util2.NGLang.alertTitle, message)) {
                await options.taskComplete(20);
              } else {
                (0, import_util2.reloadPage)();
              }
            } else {
              await options.taskComplete(20);
            }
          } else {
            await (0, import_util2.wfAlert)(import_util2.NGLang.getTaskDynamicError, resp.message);
          }
          break;
        }
        case 20: {
          if (options.taskDynamicInfo.dynamicFlowNodes && Object.keys(options.taskDynamicInfo.dynamicFlowNodes).length > 0) {
            const branchData = [];
            branchData.push(options.taskDynamicInfo.dynamicFlowNodes);
            await (0, import_util2.wfModal)({
              title: import_util2.NGLang.dynamicBranchWinTitle,
              width: 400,
              content: /* @__PURE__ */ import_react.default.createElement(
                import_WFDynamicBranchWin.WFDynamicBranchWin,
                {
                  branchData,
                  cancelBack: import_util2.reloadPage,
                  callBack: (data) => {
                    var _a2;
                    taskDealInfo.dynamicBranches = data;
                    taskDealInfo.nodeName = (_a2 = data[0]) == null ? void 0 : _a2.nodeName;
                    options.taskComplete(30);
                  }
                }
              )
            });
          } else {
            await options.taskComplete(30);
          }
          break;
        }
        case 30: {
          let nodeData = [];
          if (options.taskDynamicInfo.dynamicUserNodes && options.taskDynamicInfo.dynamicUserNodes.length > 0) {
            const targetIdList = taskDealInfo.dynamicBranches ? taskDealInfo.dynamicBranches.map((i) => i.targetNodeId) : [];
            const userNodes = options.taskDynamicInfo.dynamicUserNodes;
            const result = (0, import_util2.filterUserNodes)(targetIdList, userNodes, "dependAssignedNodes");
            nodeData = result;
          }
          if (nodeData.length === 1) {
            const _nodeData = nodeData[0];
            const radioItems = (0, import_util2.getUseDynamicType)(_nodeData.users.length > 0, _nodeData.assignAnyUsers);
            const callBack = (data) => {
              taskDealInfo.dynamicNodeUsers = [
                {
                  nodeId: _nodeData.id,
                  userNos: data.map((_d) => _d.userNo),
                  whetherCrossNode: _nodeData.whetherCrossNode
                  //是否是跨节点这个节点
                }
              ];
              options.taskComplete(40);
            };
            await (0, import_util2.wfModal)({
              title: `${_nodeData.name}${import_util2.NGLang.taskHisNode}--${import_util2.NGLang.dynamicUsers}`,
              width: 900,
              footerLeft: /* @__PURE__ */ import_react.default.createElement(import_WFDynamicNodeUserWin.WFDynamicNodeUserWinFooter, { radioItems }),
              content: /* @__PURE__ */ import_react.default.createElement(
                import_WFDynamicNodeUserWin.WFDynamicNodeUserWin,
                {
                  radioItems,
                  loginInfo: workFlowInfo.loginOrgInfo,
                  todoData: _nodeData.users,
                  callBack,
                  cancelBack: import_util2.reloadPage
                }
              )
            });
          } else if (nodeData.length > 1) {
            await (0, import_util2.wfModal)({
              title: import_util2.NGLang.nodeDynamicUsers,
              width: 650,
              content: /* @__PURE__ */ import_react.default.createElement(
                import_WFNodeUserSettingWin.WFNodeUserSettingWin,
                {
                  nodeData,
                  loginOrgInfo: workFlowInfo.loginOrgInfo,
                  callBack: (data) => {
                    taskDealInfo.dynamicNodeUsers = data.map((i, index) => {
                      return {
                        ...i,
                        whetherCrossNode: options.taskDynamicInfo.dynamicUserNodes[index].whetherCrossNode,
                        name: options.taskDynamicInfo.dynamicUserNodes[index].name
                      };
                    });
                    options.taskComplete(40);
                  }
                }
              )
            });
          } else {
            await options.taskComplete(40);
          }
          break;
        }
        case 40: {
          const resp = await (0, import_functionalComponent.usingProgress)(() => (0, import_service.compeleteTask)({ ...taskDealInfo }), {
            title: import_util2.NGLang.submitTaskComplete
          });
          if (resp.code === 0) {
            if (!resp.flowErrorMsg) {
              await options.successAlertAndClose(import_util2.NGLang.TaskCompleteSuccess);
            } else {
              await options.successAlertAndClose("任务办理成功,但" + resp.flowErrorMsg);
            }
          } else {
            await (0, import_util2.wfAlert)(import_util2.NGLang.TaskCompleteError, resp.message);
          }
          break;
        }
        default:
          break;
      }
    },
    // 抄送
    carbonCopy: async () => {
      if (!!workFlowInfo.processOperateOptions.copy && !!workFlowInfo.processOperateOptions.copy.userInfos) {
        (0, import_functionalComponent.showModal)({
          title: "抄送人员选择",
          width: 1e3,
          content: /* @__PURE__ */ import_react.default.createElement(ModalTableDom, { btnType: "copy", leftTableRef: copyLeftTable, rightTableRef: copyRightTable }),
          async onOk(ins) {
            const selectedData = copyRightTable.current.getApi().getData();
            if (!selectedData && !selectedData.length) {
              return;
            }
            const userIds = selectedData.map(({ userNo }) => userNo);
            console.log(taskDealInfo, "抄送信息");
            const res = await (0, import_service.carbonCopy)(taskDealInfo.taskId, userIds);
            if (res.code === 0) {
              await (0, import_util2.wfAlert)(
                import_util2.NGLang.carbonCopySuccess,
                `${import_util2.NGLang.carbonCopySuccessContent}${selectedData.map(({ userName }) => userName).join(",")}`
              );
            } else {
              await (0, import_util2.wfAlert)(import_util2.NGLang.carbonCopyError, res.message);
            }
          },
          onCancel(ins) {
            copyRightTable.current.getApi().setDataSource([]);
            copyLeftTable.current.getApi().setDataSource([]);
            ins.destroy();
          }
        });
      } else {
        const data = await import_util.iup.external.openHelp({
          type: "UserHelp",
          helpId: "user",
          title: import_util2.NGLang.carbonCopyUsersSelect,
          multiple: true
          // modalProps: {
          //   okText: '抄送'
          // },
        });
        if (!data || data.length === 0) {
          return;
        }
        const userIds = data.map(({ value }) => value);
        const res = await (0, import_service.carbonCopy)(taskDealInfo.taskId, userIds);
        if (res.code === 0) {
          await (0, import_util2.wfAlert)(
            import_util2.NGLang.carbonCopySuccess,
            `${import_util2.NGLang.carbonCopySuccessContent}${data.map(({ label }) => label).join(",")}`
          );
        } else {
          await (0, import_util2.wfAlert)(import_util2.NGLang.carbonCopyError, res.message);
        }
      }
    },
    //审批要点设置
    approvalPoints: async (view, callback) => {
      await (0, import_util2.wfModal)({
        title: import_util2.NGLang.approvalPoint,
        width: 800,
        content: /* @__PURE__ */ import_react.default.createElement(
          import_WFApprovalPoints.WFApprovalPoints,
          {
            approvalPointsData: workFlowInfo.approvalPoints,
            statisticsApprovalPoint: workFlowInfo.statisticsApprovalPoint,
            cancelBack: import_util2.reloadPage,
            view,
            callBack: (data) => {
              taskDealInfo.approvalPoints = data.map(({ code, name, optionValue, riskLevel, description, remark }) => ({
                code,
                name,
                optionValue,
                riskLevel,
                description,
                remark
              }));
              callback == null ? void 0 : callback();
            }
          }
        )
      });
    },
    //办理时唤起附件上传资源文件
    processAttachment: async () => {
      var _a, _b, _c, _d, _e;
      const data = await (0, import_businessComponent.openAttachment)({
        fileTypeCode: (_e = (_d = (_c = (_b = (_a = import_util.iup.getPageInstance()) == null ? void 0 : _a.getGlobalState) == null ? void 0 : _b.call(_a)) == null ? void 0 : _c.attachmentProperty) == null ? void 0 : _d.wf_file) == null ? void 0 : _e.fileTypeCode,
        asrTable: "flowAttachment",
        asrSessionGuid: taskDealInfo.guId
      });
      console.log(data, "data");
      taskDealInfo.guId = data.asrSessionGuid;
    }
  };
  const getSignatureId = (signatureId) => {
    taskDealInfo.comment = taskDealInfo.comment ? taskDealInfo.comment : {};
    taskDealInfo.comment.signatureId = signatureId;
  };
  const addWFToolBar = (0, import_util.useRefCallback)(() => {
    const tbIns = (0, import_util2.getToolbar)(toolbar);
    tbIns == null ? void 0 : tbIns.setButtons((newButtons) => {
      if (showAllToolBar) {
        newButtons = [...newButtons];
      } else {
        const showIds = ["close", "back"];
        newButtons = newButtons.filter((btn) => {
          const bId = btn.id || btn;
          return showIds.includes(bId) || (showToolBarItems == null ? void 0 : showToolBarItems.includes(bId));
        });
      }
      if (direction === "vertical") {
        return newButtons;
      }
      if (workFlowInfo.processOperateOptions.copy != void 0) {
        newButtons.unshift({
          id: "wfbtn_carboncopy",
          text: import_util2.NGLang.carbonCopy,
          icon: "SendOutlined",
          onClick: () => options.carbonCopy()
        });
      }
      newButtons.unshift({
        id: "wfbtn_flowDiagram",
        text: import_util2.NGLang.btnFlowInfo,
        icon: "HistoryOutlined",
        onClick: function() {
          (0, import_util2.showFlowInfoByPiId)(workFlowInfo.procInstId);
        }
      });
      if (Array.isArray(workFlowInfo.approvalPoints)) {
        if (workFlowInfo.approvalPoints.length > 0) {
          newButtons.unshift({
            id: "wfbtn_approvalPoint",
            text: import_util2.NGLang.approvalPoint,
            onClick: () => options.approvalPoints(false)
          });
        }
      }
      if (workFlowInfo.mustUploadApprovalAttachment) {
        newButtons.unshift({
          id: "wfbtn_attachment",
          text: import_util2.NGLang.btnAttach,
          icon: "PaperClipOutlined",
          onClick: () => {
            options.processAttachment();
          }
        });
      }
      if (workFlowInfo.processOperateOptions.terminate != void 0) {
        newButtons.unshift({
          id: "wfbtn_terminate",
          text: import_util2.NGLang.btnAbort,
          icon: "MinusCircleFilled",
          onClick: async () => {
            workFlowInfo.minCommentLen = workFlowInfo.processOperateOptions.terminate.minCommentLength;
            workFlowInfo.needsignature = workFlowInfo.processOperateOptions.terminate.requiredSignature;
            await options.flowTerminate(1);
          }
        });
      }
      if (workFlowInfo.processOperateOptions.addSubTask != void 0) {
        newButtons.unshift({
          id: "wfbtn_addsubtis",
          text: import_util2.NGLang.btnAddsubtis,
          icon: "SisternodeOutlined",
          onClick: async () => {
            workFlowInfo.minCommentLen = workFlowInfo.processOperateOptions.addSubTask.minCommentLength;
            workFlowInfo.needsignature = workFlowInfo.processOperateOptions.addSubTask.requiredSignature;
            await options.addSubTasks(1);
          }
        });
      }
      if (workFlowInfo.processOperateOptions.reassign != void 0) {
        newButtons.unshift({
          id: "wfbtn_transmit",
          text: import_util2.NGLang.btntransmit,
          icon: "NodeExpandOutlined",
          onClick: async () => {
            workFlowInfo.minCommentLen = workFlowInfo.processOperateOptions.reassign.minCommentLength;
            workFlowInfo.needsignature = workFlowInfo.processOperateOptions.reassign.requiredSignature;
            await options.taskReassign(1);
          }
        });
      }
      if (workFlowInfo.processOperateOptions.rollback != void 0) {
        newButtons.unshift({
          id: "wfbtn_rollback",
          text: import_util2.NGLang.btnrollback,
          icon: "RollbackOutlined",
          onClick: async () => {
            workFlowInfo.minCommentLen = workFlowInfo.processOperateOptions.rollback.minCommentLength;
            workFlowInfo.needsignature = workFlowInfo.processOperateOptions.rollback.requiredSignature;
            await options.rollBack(0);
          }
        });
      }
      if (workFlowInfo.processOperateOptions.disagree != void 0) {
        newButtons.unshift({
          id: "wfbtn_disagree",
          text: import_util2.NGLang.btnDisagree,
          icon: "CloseSquareFilled",
          onClick: async () => {
            taskDealInfo.action = workFlowInfo.processOperateOptions.disagree.operation;
            workFlowInfo.minCommentLen = workFlowInfo.processOperateOptions.disagree.minCommentLength;
            workFlowInfo.needsignature = workFlowInfo.processOperateOptions.disagree.requiredSignature;
            await options.taskComplete(40);
          }
        });
      }
      if (workFlowInfo.processOperateOptions.agree != void 0) {
        newButtons.unshift({
          id: "wfbtn_agree",
          text: import_util2.NGLang.btnAgree,
          icon: "CheckCircleFilled",
          onClick: async () => {
            taskDealInfo.action = workFlowInfo.processOperateOptions.agree.operation;
            workFlowInfo.minCommentLen = workFlowInfo.processOperateOptions.agree.minCommentLength;
            workFlowInfo.needsignature = workFlowInfo.processOperateOptions.agree.requiredSignature;
            await options.taskComplete(0);
          }
        });
      }
      if (workFlowInfo.processOperateOptions.submit != void 0) {
        newButtons.unshift({
          id: "wfbtn_taskcomplete",
          text: import_util2.NGLang.btnSubmit,
          icon: "CheckSquareFilled",
          onClick: async () => {
            taskDealInfo.action = workFlowInfo.processOperateOptions.submit.operation;
            workFlowInfo.minCommentLen = workFlowInfo.processOperateOptions.submit.minCommentLength;
            workFlowInfo.needsignature = workFlowInfo.processOperateOptions.submit.requiredSignature;
            await options.taskComplete(0);
          }
        });
      }
      return newButtons;
    });
  });
  (0, import_util.useAllReady)(() => {
    addWFToolBar();
    (0, import_util2.setWorkFlowUIState)(workFlowInfo.formDataPermissions, workFlowInfo.menuPermissions);
  });
  const msgHeight = msg.system_message || msg.mobile_message ? 38 : 0;
  return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, direction === "horizontal" ? /* @__PURE__ */ import_react.default.createElement(
    import_util.Layout,
    {
      style: {
        height: height + msgHeight,
        padding: 5,
        backgroundColor: "var(--component-background)",
        marginBottom: "var(--inner-margin, 16px)"
      }
    },
    /* @__PURE__ */ import_react.default.createElement(import_util.Layout.Flex, { direction: "row" }, /* @__PURE__ */ import_react.default.createElement(
      import_util.Layout.Slider,
      {
        size: workFlowInfo.remarkPanelWidth || 250,
        style: { marginRight: 5 }
      },
      /* @__PURE__ */ import_react.default.createElement(import_util.Layout, null, /* @__PURE__ */ import_react.default.createElement(import_util.Layout, { direction: "row", style: { alignItems: "center" } }, /* @__PURE__ */ import_react.default.createElement(
        import_baseComponent.Select,
        {
          onChange: onSuggestChange,
          options: commonWordHelp.map((i) => ({ label: i.content, value: i.id })),
          style: { flex: 1, width: 0 },
          size: "small"
        }
      ), /* @__PURE__ */ import_react.default.createElement(
        import_icons.FormOutlined,
        {
          onClick: () => {
            (0, import_util2.wfModal)({
              title: import_util2.NGLang.commonPhrases,
              width: 800,
              cancelText: "",
              content: /* @__PURE__ */ import_react.default.createElement(
                import_WFCommonPhrases.WFCommonPhrases,
                {
                  callback: () => {
                    (0, import_service.getCommonWordHelp)().then((res) => {
                      setCommonWordHelp(res);
                    });
                  }
                }
              )
            });
          },
          style: { margin: "0 6px" }
        }
      )), /* @__PURE__ */ import_react.default.createElement(import_util.Layout.Flex, { direction: "row", style: { margin: "2px 0" } }, /* @__PURE__ */ import_react.default.createElement(
        import_baseComponent.TextArea,
        {
          id: "SuggestValue",
          placeholder: import_util2.NGLang.emptyRemarkInfo,
          style: { flex: 1, resize: "none" }
        }
      ), workFlowInfo.signatureFlag && /* @__PURE__ */ import_react.default.createElement(
        import_NGSignatureImage.WfSignatureImage,
        {
          onChange: onSignatureChange,
          signature,
          style: { width: 100, marginLeft: 2 }
        }
      )))
    ), /* @__PURE__ */ import_react.default.createElement(import_util.Layout.Flex, null, /* @__PURE__ */ import_react.default.createElement(HistoryTable, null))),
    msgHeight > 0 && /* @__PURE__ */ import_react.default.createElement(import_util.Layout, { direction: "row", style: { ...import_util2.commonStyle.borderStyle, padding: 5, marginTop: -1, borderTop: 0 } }, /* @__PURE__ */ import_react.default.createElement(FormItem, { flex: 3 }, /* @__PURE__ */ import_react.default.createElement(import_baseComponent.Input, { id: "messageContent", placeholder: import_util2.NGLang.msgContent })), /* @__PURE__ */ import_react.default.createElement(FormItem, { flex: 2, label: import_util2.NGLang.msgReceiver, style: { marginLeft: 10 } }, /* @__PURE__ */ import_react.default.createElement(import_WFNoticeUserSelect.WFNoticeUserSelect, { id: "messageUsers" })))
  ) : /* @__PURE__ */ import_react.default.createElement(
    import_WFVerticalPanel.WFVerticalPanel,
    {
      options,
      workFlowInfo,
      taskDealInfo,
      commonWordHelp,
      getSignatureId
    }
  ));
}
function WorkFlowPanel(props) {
  const wfOType = props.wfOType || import_util.iup.getQueryValue("wfotype");
  const wfTaskId = props.wfTaskId || import_util.iup.getQueryValue("wftaskid");
  const wfPiId = props.wfPiId || import_util.iup.getQueryValue("wfpiid");
  const bizType = props.bizType || import_util.iup.getQueryValue("bizCode") || import_util.iup.getQueryValue("bizType");
  const oType = props.oType || import_util.iup.getQueryValue("otype");
  const bizPhId = props.bizPhId || import_util.iup.getQueryValue("id");
  const copyId = import_util.iup.getQueryValue("copyId");
  const nodeDefKey = import_util.iup.getQueryValue("nodeDefKey");
  const isFromPortal = props.isFromPortal || import_util.iup.getQueryValue("isFromProtal") === "true" || import_util.iup.getQueryValue("isFromPortal") === "true";
  const refreshTaskList = props.refreshTaskList || import_util.iup.getQueryValue("iswftasklist") === "true";
  const [workFlowInfo, setWorkFlowInfo] = (0, import_react.useState)(null);
  const [collapsed, setCollapsed] = (0, import_react.useState)(false);
  const switchCollapsed = () => {
    setCollapsed(!collapsed);
  };
  (0, import_util.useAsyncEffect)(
    async (ctx) => {
      if (oType !== "add" && !!wfPiId) {
        const info = await (0, import_service.getWorkFlowInfo)({ wfPiId, wfOType, wfTaskId, copyId, nodeDefKey });
        if (ctx.isMounted) {
          info && setWorkFlowInfo(info);
        }
      }
    },
    [oType, wfPiId, wfOType, wfTaskId]
  );
  if (oType === "add" || !wfPiId) {
    return null;
  }
  if (!workFlowInfo) {
    return props.direction === "horizontal" ? /* @__PURE__ */ import_react.default.createElement(WfSkeleton, { height: props.height + 8 }) : /* @__PURE__ */ import_react.default.createElement("div", { style: { width: 460 } }, /* @__PURE__ */ import_react.default.createElement(WfSkeleton, { height: 460 }));
  }
  if (props.direction === "vertical" && props.slider !== false) {
    return /* @__PURE__ */ import_react.default.createElement(import_util.Layout, { autoFit: true, direction: "row", style: { width: "auto", marginLeft: "var(--inner-margin, 16px)" } }, /* @__PURE__ */ import_react.default.createElement(
      import_util.Layout.Slider,
      {
        size: 460,
        collapsed,
        draggable: false,
        icon: /* @__PURE__ */ import_react.default.createElement(IconBar, { collapsed, onChange: switchCollapsed }),
        style: { overflow: "auto" }
      },
      /* @__PURE__ */ import_react.default.createElement(
        InnerWorkFlowPanel,
        {
          ...props,
          workFlowInfo,
          isFromPortal,
          refreshTaskList,
          oType,
          bizType,
          bizPhId
        }
      )
    ));
  }
  return /* @__PURE__ */ import_react.default.createElement(
    InnerWorkFlowPanel,
    {
      ...props,
      workFlowInfo,
      isFromPortal,
      refreshTaskList,
      oType,
      bizType,
      bizPhId
    }
  );
}
WorkFlowPanel.defaultProps = {
  oType: "edit",
  height: 180,
  slider: true,
  showToolBarItems: [],
  bizType: "",
  bizPhId: "",
  isFromPortal: false,
  refreshTaskList: false,
  bizSaveFn: import_util.emptyFn,
  bizRollbackSaveFn: import_util.emptyFn,
  getAttachData: import_util.emptyFn,
  showAllToolBar: false,
  taskDealInfo: {},
  direction: "horizontal"
};
function IconBar({ collapsed, onChange, style, className }) {
  return /* @__PURE__ */ import_react.default.createElement("div", { className, onClick: onChange, style }, /* @__PURE__ */ import_react.default.createElement(
    "span",
    {
      style: {
        transform: `rotate(${collapsed ? 180 : 0}deg)`,
        borderLeft: "4px solid #fff",
        borderTop: "4px solid transparent",
        borderBottom: "4px solid transparent"
      }
    }
  ));
}
